package com.pro.controller;

import com.pro.pojo.JsGoodsCount;
import com.pro.pojo.JsProductCategroy;
import com.pro.pojo.JsonData;
import com.pro.service.JsProductCategroyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/goodsTree")
public class JsProductCategroyController {

    @Autowired
    private JsProductCategroyService service;
    @RequestMapping("/getTree")
    public JsonData getTree(){
        List<JsProductCategroy> list = service.getTree();

        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务端错误");
    }
    @RequestMapping("/delProductCategroy")
    public JsonData delProductCategroy(Integer categroyId){
        Boolean aBoolean = service.delProductCategroy(categroyId);

        return aBoolean!= false?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }

    @RequestMapping("/updateProductCategroy")
    public JsonData updateProductCategroy(JsProductCategroy jsProductCategroy){
        Boolean aBoolean = service.updateProductCategroy(jsProductCategroy);

        return aBoolean!= false?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");

    }
    @RequestMapping("/addProductCategroy")
    public JsonData addProductCategroy(JsProductCategroy jsProductCategroy){
        Boolean aBoolean = service.addProductCategroy(jsProductCategroy);

        return aBoolean!= false?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");

    }
    //商品类型对应的收藏量
    @RequestMapping("/collectionCount")
    public JsonData collectionCount(){
        List<JsGoodsCount> collectionCount = service.collectionCount();
        return collectionCount!=null?JsonData.buildSuccess(collectionCount):JsonData.buildError("服务端错误");
    }
    //商品类型对应的点击量
    @RequestMapping("/hitsSum")
    public JsonData hitsSum(){
        List<JsGoodsCount> hitsSum = service.hitsSum();
        return hitsSum!=null?JsonData.buildSuccess(hitsSum):JsonData.buildError("服务端错误");
    }
    //商品类型对应的评论量
    @RequestMapping("/commentSum")
    public JsonData commentSum(){
        List<JsGoodsCount> commentSum = service.commentSum();
        return commentSum!=null?JsonData.buildSuccess(commentSum):JsonData.buildError("服务端错误");
    }

}
